<template>
	<view class="beijingse mainpadding2" v-if="pageShow">
		<!-- 租买车 -->
		<view class="" v-if="type==1">
			<view class="ffffff radius margin_top mainpadding">
				<view class="ershiba zhonghei fonweight">订单商品</view>
				<view class="flextop margin_top" @click="jumpdetail('/pages_index/chexingxq?id=',dataAll.car_id)">
					<image class="sptp" :src="dataAll.car_image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{dataAll.car_name}}</view>
						<view class="strongtext xiaohui">{{dataAll.difference}}</view>
						<view class="flexbetween " style="width: 100%;">
							<view class="titletext xiaohong fonweight">{{dataAll.pay_price}}</view>
							<view class="ershil xiaohui">x1</view>
						</view>
					</view>
				</view>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween">
					<view class="ershil zhonghei">合计</view>
					<view class="ershil xiaohuang">￥{{dataAll.pay_price}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==2 || dataAll.state==3">
					<view class="ershil zhonghei">支付方式</view>
					<view class="ershil xiaohuang">{{dataAll.pay_type==10?"微信支付":dataAll.pay_type==20?"支付宝支付":("积分支付："+dataAll.score)}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">订单编号</view>
					<view class="ershil xiaohui">{{dataAll.order_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">下单时间</view>
					<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
				</view>
			</view>
		</view>
		<!-- 住宿 -->
		<view class="" v-if="type==2">
			<view class="ffffff radius margin_top mainpadding">
				<view class="ershiba zhonghei fonweight">订单商品</view>
				<view class="flextop margin_top" @click="jumpdetail('/pages_index/fangjianxq?id=',dataAll.hotel_type_id)">
					<image class="sptp" :src="dataAll.hoteltype.image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{dataAll.hoteltype.name}}</view>
						<view class="flexbetween " style="width: 100%;">
							<view class="titletext xiaohong fonweight">{{dataAll.pay_price}}</view>
							<view class="ershil xiaohui">x1</view>
						</view>
					</view>
				</view>
			</view>
			<view class="ffffff mainpadding radius margin_top">
				<view class="titletext zhonghei fonweight">使用门店</view>
				<view class="flexbetween">
					<view class="">
						<view class="titletext zhonghei margin_top">{{dataAll.hotel.name}}</view>
						<view class="ershil xiaohui margin_top1">{{dataAll.hotel.detail}}</view>
					</view>
					<image style="width: 58rpx;height: 58rpx;" src="../static/images/system/daohang.png" mode="" @click="openmap(1)">
					</image>
				</view>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween">
					<view class="ershil zhonghei">合计</view>
					<view class="ershil xiaohuang">{{dataAll.pay_price}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.order_status==20 || dataAll.order_status==30">
					<view class="ershil zhonghei">支付方式</view>
					<view class="ershil xiaohuang">{{dataAll.pay_type==10?"微信支付":dataAll.pay_type==20?"支付宝支付":("积分支付："+dataAll.score)}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">订单编号</view>
					<view class="ershil xiaohui">{{dataAll.order_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">下单时间</view>
					<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
				</view>
			</view>
		</view>
		<!-- 餐饮 -->
		<view class="" v-if="type==3">
			<view class="ffffff radius margin_top mainpadding">
				<view class="ershiba zhonghei fonweight">订单商品</view>
				<view class="flextop margin_top" @click="jumpdetail('/pages_index/canyinxq?id=',dataAll.foodshop_id)" v-for="ite in dataAll.goods" :key="ite.id">
					<image class="sptp" :src="ite.image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{ite.title}}</view>
						<view class="strongtext xiaohui">{{ite.difference}}</view>
						<view class="flexbetween" style="width: 100%;">
							<view class="titletext xiaohong fonweight">{{ite.price}}</view>
							<view class="ershil xiaocheng">x{{ite.number}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="ffffff mainpadding radius margin_top">
				<view class="titletext zhonghei fonweight">使用门店</view>
				<view class="flexbetween">
					<view class="">
						<view class="titletext zhonghei margin_top">{{dataAll.foodshop.name}}</view>
						
						<view class="ershil xiaohui margin_top1">{{dataAll.foodshop.detail}}</view>
					</view>
					<image style="width: 58rpx;height: 58rpx;" src="../static/images/system/daohang.png" mode="" @click="openmap(2)">
					</image>
				</view>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween">
					<view class="ershil zhonghei">合计</view>
					<view class="ershil xiaohuang">{{dataAll.pay_price}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==2 || dataAll.state==3">
					<view class="ershil zhonghei">支付方式</view>
					<view class="ershil xiaohuang">{{dataAll.pay_type==10?"微信支付":dataAll.pay_type==20?"支付宝支付":("积分支付："+dataAll.score)}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">订单编号</view>
					<view class="ershil xiaohui">{{dataAll.order_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">下单时间</view>
					<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
				</view>
			</view>
		</view>
		<!-- 养护 -->
		<view class="" v-if="type==4">
			<view class="ffffff radius margin_top mainpadding">
				<view class="ershiba zhonghei fonweight">订单商品</view>
				<view class="flextop margin_top "  @click="jumpdetail('/pages_index/shangpxqweihcl?id=',dataAll.carshop_goods_id)">
					<image class="sptp" :src="dataAll.carshop_goods_image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{dataAll.carshop_goods_name}}</view>
						<view class="flexbetween" style="width: 100%;">
							<view class="titletext xiaohong fonweight">¥{{dataAll.pay_price}}</view>
							<view class="ershil xiaocheng">x1</view>
						</view>
					</view>
				</view>
			</view>
			<view class="ffffff mainpadding radius margin_top">
				<view class="titletext zhonghei fonweight">使用门店</view>
				<view class="flexbetween">
					<view class="">
						<view class="titletext zhonghei margin_top">{{dataAll.carshop.name}}</view>
						<view class="ershil xiaohui margin_top1">{{dataAll.carshop.detail}}</view>
					</view>
					<image style="width: 58rpx;height: 58rpx;" src="../static/images/system/daohang.png" mode="" @click="openmap(3)">
					</image>
				</view>
			</view>
			<view class="ffffff radius mainpadding margin_top">
				<view class="flexbetween">
					<view class="ershil zhonghei">合计</view>
					<view class="ershil xiaohuang">{{dataAll.pay_price}}</view>
				</view>
				<view class="flexbetween margin_top" v-if="dataAll.state==2 || dataAll.state==3">
					<view class="ershil zhonghei">支付方式</view>
					<view class="ershil xiaohuang">{{dataAll.pay_type==10?"微信支付":dataAll.pay_type==20?"支付宝支付":("积分支付："+dataAll.score)}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">订单编号</view>
					<view class="ershil xiaohui">{{dataAll.order_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil zhonghei">下单时间</view>
					<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
				</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding">
			<view class="flexright" v-if="type==1">
				<view class="qxbtn flexcenter" v-if="dataAll.state==1" @click.stop="cancelItem(dataAll.id,'/api/carordercl/cancelOrder')">取消订单</view>
				<view class="xhbtn flexcenter margin_left2" v-if="dataAll.state==1" @click.stop="tzzf(1,dataAll)">立即支付</view>
				
				<view class="xhbtn flexcenter" v-if="dataAll.state==3 && dataAll.comment_status==1" @click.stop="tzljpj(1,dataAll.id)">立即评价</view>
				<view class="qxbtn flexcenter margin_left2" v-if="dataAll.state==3 || dataAll.state==4" @click.stop="delItem(dataAll.id,'/api/carordercl/delOrder')">删除订单</view>
			</view>
			<view class="flexright" v-if="type==2">
				<view class="qxbtn flexcenter" v-if="dataAll.order_status==10" @click.stop="cancelItem(dataAll.id,'/api/Hotelordercl/cancelOrder')">取消订单</view>
				<view class="xhbtn flexcenter margin_left2" v-if="dataAll.order_status==10" @click.stop="tzzf(2,dataAll)">立即支付</view>
				<view class="xhbtn flexcenter" v-if="dataAll.order_status==30 && dataAll.comment_status==10" @click.stop="tzljpj(2,dataAll.id)">立即评价</view>
				<view class="qxbtn flexcenter margin_left2" v-if="dataAll.order_status==30 || dataAll.order_status==-10" @click.stop="delItem(dataAll.id,'/api/Hotelordercl/delOrder')">删除订单</view>
			</view>
			<view class="flexright" v-if="type==3">
				<view class="qxbtn flexcenter" v-if="dataAll.state==1" @click.stop="cancelItem(dataAll.id,'/api/Foodshoporder/cancelOrder')">取消订单</view>
				<view class="xhbtn flexcenter margin_left2" v-if="dataAll.state==1" @click.stop="tzzf(4,dataAll)">立即支付</view>
				
				<view class="xhbtn flexcenter" v-if="dataAll.state==3 && dataAll.comment_status==1" @click.stop="tzljpj(3,dataAll.id)">立即评价</view>
				<view class="qxbtn flexcenter margin_left2" v-if="dataAll.state==3 || dataAll.state==4" @click.stop="delItem(dataAll.id,'/api/Foodshoporder/delOrder')">删除订单</view>
			</view>
			<view class="flexright" v-if="type==4">
				<view class="qxbtn flexcenter" v-if="dataAll.state==1" @click.stop="cancelItem(dataAll.id,'/api/Carshopordercl/cancelOrder')">取消订单</view>
				<view class="xhbtn flexcenter margin_left2" v-if="dataAll.state==1" @click.stop="tzzf(3,dataAll)">立即支付</view>
				
				<view class="xhbtn flexcenter" v-if="dataAll.state==3 && dataAll.comment_status==1" @click.stop="tzljpj(4,dataAll.id)">立即评价</view>
				<view class="qxbtn flexcenter margin_left2" v-if="dataAll.state==3 || dataAll.state==4" @click.stop="delItem(dataAll.id,'/api/Carshopordercl/delOrder')">删除订单</view>
			</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type:1,//1租买车，2住宿，3餐饮，4养护
				listid:"",
				dataAll:{},
				pageShow:false,
				modal:{
					modalShow:false,
					title:"",
				},
				currentapi:"",
				currentid:""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.type = options.type
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			// 跳转立即评价
			tzljpj(type,id){
				uni.navigateTo({
					url:'/pages_mypage/tiaozhuanlijipj?type='+type+"&id="+id
				})
			},
			tzzf(val,item){
				let data = {
					order_id:item.id,
					pay_price:item.pay_price,
					pay_score:item.score,
					type:val
				}
				uni.navigateTo({
					url: '/pages_index/zhifuTwo?msg='+encodeURIComponent(JSON.stringify(data))
				})
			},
			cancelItem(id,url){
				this.currentapi = url
				this.currentid = id
				this.modal.title="是否确认取消订单？"
				this.modal.modalShow = true
			},
			delItem(id,url){
				this.currentapi = url
				this.currentid = id
				this.modal.title="是否确认删除当前订单？"
				this.modal.modalShow = true
			},
			modalSure(){
				if(this.modal.title=="是否确认取消订单？"){
					this.cancelorder()
				}else if(this.modal.title=="是否确认删除当前订单？"){
					this.delOrder()
				}
				this.modalcancel()
			},
			modalcancel(){
				this.modal.modalShow = false
			},
			cancelorder(){
				httpRequest.request(this.currentapi, 'GET', {
					order_id: this.currentid,
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.getDetail()
					}
				})
			},
			delOrder(){
				httpRequest.request(this.currentapi, 'POST', {
					id: this.currentid,
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
			getDetail(){
				let url = "/api/carordercl/getOrderInfo"//租买车
				if(this.type==2){//住宿
					url = "/api/Hotelordercl/detail"
				}
				if(this.type==3){//餐饮
					url = "/api/Foodshoporder/getOrderInfo"
				}
				if(this.type==4){//养护
					url = "/api/Carshopordercl/getOrderInfo"
				}
				httpRequest.request(url, 'GET', {
					id: this.listid,
				}).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
			openmap(val){
				if(val==1){//住宿
					uni.openLocation({
					     latitude: Number(this.dataAll.hotel.lat),//即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					     longitude:Number(this.dataAll.hotel.lng),//即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					     name: this.dataAll.hotel.name,//即将传到高德或腾讯地图的店铺名称
					     address: this.dataAll.hotel.detail,//即将传到高德或腾讯地图的详细地址
					     scale: 18
					})
				}
				if(val==2){//餐饮
					uni.openLocation({
					     latitude: Number(this.dataAll.foodshop.lat),//即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					     longitude:Number(this.dataAll.foodshop.lng),//即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					     name: this.dataAll.foodshop.name,//即将传到高德或腾讯地图的店铺名称
					     address: this.dataAll.foodshop.detail,//即将传到高德或腾讯地图的详细地址
					     scale: 18
					})
				}
				if(val==3){//养护
					uni.openLocation({
					     latitude: Number(this.dataAll.carshop.lat),//即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					     longitude:Number(this.dataAll.carshop.lng),//即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					     name: this.dataAll.carshop.name,//即将传到高德或腾讯地图的店铺名称
					     address: this.dataAll.carshop.detail,//即将传到高德或腾讯地图的详细地址
					     scale: 18
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.hexm {
		width: 167rpx;
		height: 167rpx;
		margin: auto;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.xhbtn {
		width: 170rpx;
		height: 67rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
		border-radius: 120rpx;
		border: 2rpx solid #FF9341;
	}

	.qxbtn {
		width: 170rpx;
		height: 67rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #666666;
		border-radius: 120rpx;
		border: 2rpx solid #666666;
	}

	.sptp {
		width: 124rpx;
		height: 124rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
</style>